package Demo2;

import java.util.ArrayList;

public class Main {
    public static void main(String[] args) {
//        创建抽奖器对象，指定数据类型
        ProductGetter<String> stringProductGetter = new ProductGetter<>();
//        填充奖品
        String[] str = {"扫地机器人", "HUAWEI Mate 40", "iPhone 12", "咖啡机", "洗护大礼包", "Dior口红", "烤箱"};
        for (int i = 0; i < str.length; i++) {
            stringProductGetter.addProduct(str[i]);
        }
//        抽奖
        String product1 = stringProductGetter.getProduct();
        System.out.println("恭喜您，抽中了" + product1);

        System.out.println("----------------------------------");
        ProductGetter<Integer> integerProductGetter = new ProductGetter<>();
        int[] intProducts = {50, 100, 200, 500, 1000, 5000, 10000};
        for (int i = 0; i < intProducts.length; i++) {
            integerProductGetter.addProduct(intProducts[i]);
        }

        Integer product2 = integerProductGetter.getProduct();
        System.out.println("恭喜您，抽中了" + product2 + "元奖金");

        System.out.println("-----------------------------------");
        ProductGetter<Integer> productGetter = new ProductGetter<>();
        ArrayList<String> strList = new ArrayList<>();
        strList.add("笔记本电脑");
        strList.add("iPhone 12");
        strList.add("jk制服");
//        泛型方法调用
        String product3 = productGetter.getProduct(strList);
        System.out.println(product3 + "\t" + product3.getClass().getSimpleName());
    }
}
